#include "Download.h"
#include "Settings.h"
#include <QDebug>

int Download::downloadsCounter = 0;

Download::Download(QString name, QString savingPath,
						   QString downloadLink, int priority,
						   int id, bool finished, bool started,
						   int progress):
	QObject(0), id(id), name(name), savingPath(savingPath),
	downloadLink(downloadLink), progress(progress),
	priority(priority), finished(finished), started(started)
{
}

int Download::getDownloadsCounter()
{
	return downloadsCounter;
}

void Download::setDownloadsCounter(int downloadsCounter)
{
	Download::downloadsCounter = downloadsCounter;
}

int Download::getId()
{
	return id;
}

void Download::setStarted(bool started)
{
	this->started = started;
}

bool Download::isRunning()
{
	return started && !finished;
}

void Download::start()
{
	setStarted(true);
}

void Download::stop()
{
	qDebug() << "Download::stop()";
	setStarted(false);
	progress = 0;
	emit canceled();
}

bool Download::isStarted()
{
	return started;
}

void Download::setFinished(bool finished)
{
	this->finished = finished;
}

bool Download::isFinished()
{
	return finished;
}

void Download::setPriority(int priority)
{
	this->priority = priority;
}

int Download::getPriority()
{
	return priority;
}

void Download::setProgerss(int progress)
{
	this->progress = progress;
}

void Download::finish()
{
	setFinished(true);
}

int Download::getProgress()
{
	return progress;
}

void Download::setDownloadLink(QString downloadLink)
{
	this->downloadLink = downloadLink;
}

QString Download::getDownloadLink()
{
	return downloadLink;
}

void Download::setSavingPath(QString savingPath)
{
	this->savingPath = savingPath;
}

QString Download::getSavingPath()
{
	return savingPath;
}

void Download::setName(QString name)
{
	this->name = name;
}

QString Download::getName()
{
	return name;
}

void Download::setId(int id)
{
	this->id = id;
}

